package com.elite.groovy.callback

import com.elite.groovy.davco.clink.ClinkUtils
import com.elite.groovy.kh.KHUtil
import com.elite.groovy.kh.LogToDB
import com.elite.groovy.util.EliteBean
import net.sf.json.JSONArray
import net.sf.json.JSONObject
import org.apache.commons.logging.Log
import org.apache.commons.logging.LogFactory
import org.springframework.jdbc.core.JdbcTemplate

import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
import java.text.SimpleDateFormat

/**
 * @projectName: Groovy
 * @package: com.elite.groovy.callback
 * @className: apiClinkReportData
 * @description: 同步天润报表
 * @author: LiJT
 * @date: 2023-10-27 11:13
 * @version: 1.0
 */

public class apiClinkReportData implements ServiceBackInvoke {
    private static final Log log = LogFactory.getLog(apiClinkReportData.class);

    private static Map<String, String> headMap = new HashMap<String, String>();
    private static SimpleDateFormat sdf_Oper_No = new SimpleDateFormat("yyyyMMddHHmmssSSS");
    private static String Oper_No = "";

    public String doCallBack(EliteBean eliteBean, HttpServletRequest request, HttpServletResponse response) {

        response.setCharacterEncoding("UTF-8");
        response.setContentType("application/json;charset=UTF-8");

        // 封装调用头Heads
        headMap.put("Content-Type", "application/json");

        try {
            // 获取数据源
            JdbcTemplate jt = new JdbcTemplate(eliteBean.getDataSource());

            // 创建日期格式对象并设置要输出的格式
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
            Date date = new Date();

            String StartTime = request.getParameter("StartTime");
            log.debug("同步天润报表 API StartTime:" + StartTime);

            // 如果没有传指定日期则对前一天数据重新跑以下防止部分报表平台T+1
            if (KHUtil.isNull(StartTime)) {
                Calendar tmpstartDate = Calendar.getInstance();

                tmpstartDate.add(Calendar.DATE, -1);
                String tmpStartTime = sdf.format(tmpstartDate.getTime());
                log.debug("同步天润报表(如果没有传指定日期则对前一天数据重新跑以下防止部分报表平台T+1) StartTime:" + StartTime);
                stat_report_main(eliteBean, jt, tmpStartTime, date);
            }

            // 正常跑当天数据
            StartTime = KHUtil.isNull(StartTime) ? sdf.format(date) : StartTime;
            log.debug("同步天润报表 数据 StartTime:" + StartTime);

            stat_report_main(eliteBean, jt, StartTime, date);

            log.debug("同步天润报表 任务结束执行...");
        } catch (Exception e) {
            log.error("HTTP请求调用错误，接口处理异常：" + e.getMessage(), e);
            return e.getMessage();

        }

        return "SUCC";

    }

    //
    static String stat_report_main(EliteBean eliteBean, JdbcTemplate jt, String StartTime, Date date) {

        Oper_No = StartTime + "_" + sdf_Oper_No.format(date);
        log.debug("同步天润报表 数据 Oper_No:" + Oper_No);

        // 同步8.11. IVR报表-IVR统计
        log.debug("8.11. IVR报表-IVR统计...Result:" + stat_ivr_list(eliteBean, jt, StartTime));

        // 同步8.12. IVR报表-IVR节点统计
        log.debug("8.12. IVR报表-IVR节点统计...Result:" + stat_ivr_nodes(eliteBean, jt, StartTime));

        // 同步 8.2. 座席报表统计
        log.debug("8.2. 座席报表统计...Result:" + stat_client(eliteBean, jt, StartTime));

    }

    // 8.11. IVR报表-IVR统计
    static String stat_ivr_list(EliteBean eliteBean, JdbcTemplate jt, String StartTime) {

        //处理主数据
        log.debug("8.11. IVR报表-IVR统计 toDoGet Data StartTime:" + StartTime);

        long startTime_Loop = System.currentTimeMillis();

        // 系统接入-GET
        String getPath = "/cc/stat_ivr_list?";

        Map<String, String> queryParams = new HashMap<String, String>();
        queryParams.put("date", StartTime);
        log.debug("8.11. IVR报表-IVR统计 系统接入 queryParams:" + queryParams);

        String doGETRes = ClinkUtils.doClinkCall("GET", getPath, queryParams, headMap, null);
        log.debug("8.11. IVR报表-IVR统计 系统接入 doGETRes:" + doGETRes);

        JSONObject doGETJSON = JSONObject.fromObject(doGETRes);
        log.debug("8.11. IVR报表-IVR统计 Data Result:" + doGETJSON);

        JSONArray dataArray = doGETJSON.getJSONArray("statIvrList"); ;
        int totalNum = dataArray.size();
        log.info("8.11. IVR报表-IVR统计 Data Result size:" + totalNum);

        // 初始化写入语句
        String insertSQL = '''Replace Into Clink_Stat_Ivr_List
                      (Id,
                       Date,
                       Ivrid,
                       Ivr,
                       Ivrentercount,
                       Enterqueuecount,
                       Ivrabandoncount,
                       Ivrrepeatcallrate,
                       Ivrtotaltime,
                       Ivravgtotaltime,
                       Sync_Time)
                    Values
                      (Uuid(), ?, ?, ?, ?, ?, ?, ?, ?, ?, Now())''';

        JSONObject dataObject = null;
        for (int i = 0; i < totalNum; i++) {
            dataObject = dataArray.getJSONObject(i);

            String date = KHUtil.GetSFJV(dataObject, "date");
            String ivrId = KHUtil.GetSFJV(dataObject, "ivrId");
            String ivr = KHUtil.GetSFJV(dataObject, "ivr");
            String ivrEnterCount = KHUtil.GetSFJV(dataObject, "ivrEnterCount");
            String enterQueueCount = KHUtil.GetSFJV(dataObject, "enterQueueCount");
            String ivrAbandonCount = KHUtil.GetSFJV(dataObject, "ivrAbandonCount");
            String ivrRepeatCallRate = KHUtil.GetSFJV(dataObject, "ivrRepeatCallRate");
            String ivrTotalTime = KHUtil.GetSFJV(dataObject, "ivrTotalTime");
            String ivrAvgTotalTime = KHUtil.GetSFJV(dataObject, "ivrAvgTotalTime");

            jt.update(insertSQL, date, ivrId, ivr, ivrEnterCount, enterQueueCount, ivrAbandonCount, ivrRepeatCallRate, ivrTotalTime, ivrAvgTotalTime);

        }

        LogToDB.toSyncFile_Log(eliteBean, Oper_No + KHUtil.getIntRandom(4), "8.11. IVR报表-IVR统计", "apiClinkReportData", "stat_ivr_list", getPath, "", String.valueOf(totalNum), " 总数量:" + totalNum, String.valueOf(System.currentTimeMillis() - startTime_Loop));

        return "总数量:" + totalNum;

    }

    // 8.12. IVR报表-IVR节点统计
    static String stat_ivr_nodes(EliteBean eliteBean, JdbcTemplate jt, String StartTime) {

        //处理主数据
        log.debug("8.12. IVR报表-IVR节点统计 toDoGet Data StartTime:" + StartTime);

        long startTime_Loop = System.currentTimeMillis();
        int loopLimit = 0;

        // 系统接入-GET
        String getPath = "/cc/stat_ivr_nodes?";

        Map<String, String> queryParams = new HashMap<String, String>();
        queryParams.put("date", StartTime);
        log.debug("8.12. IVR报表-IVR节点统计 系统接入 queryParams:" + queryParams);

        String doGETRes = ClinkUtils.doClinkCall("GET", getPath, queryParams, headMap, null);
        log.debug("8.12. IVR报表-IVR节点统计 系统接入 doGETRes:" + doGETRes);

        JSONObject doGETJSON = JSONObject.fromObject(doGETRes);
        log.debug("8.12. IVR报表-IVR节点统计 Data Result:" + doGETJSON);

        JSONArray dataArray = doGETJSON.getJSONArray("statIvrNodes"); ;
        int totalNum = dataArray.size();
        log.info("8.12. IVR报表-IVR节点统计 Data Result size:" + totalNum);

        // 初始化写入语句
        String insertSQL = '''Replace Into Clink_Stat_Ivr_Nodes
                                  (Id, Date, Ivrname, Ivrnode, Ivrcount, Sync_Time)
                                Values
                                  (Uuid(), ?, ?, ?, ?, Now())''';

        JSONObject dataObject = null;
        JSONObject ivrObject = null;
        for (int i = 0; i < totalNum; i++) {
            dataObject = dataArray.getJSONObject(i);

            String ivrName = KHUtil.GetSFJV(dataObject, "ivrName");
            JSONArray ivrNodes = dataObject.getJSONArray("data");

            for (int j = 0; j < ivrNodes.size(); j++) {
                ivrObject = ivrNodes.getJSONObject(j);
                String ivrNode = KHUtil.GetSFJV(ivrObject, "ivrNode");
                String count = KHUtil.GetSFJV(ivrObject, "count");

                jt.update(insertSQL, StartTime, ivrName, ivrNode, count);
                loopLimit++;
            }
        }

        LogToDB.toSyncFile_Log(eliteBean, Oper_No + KHUtil.getIntRandom(4), "8.12. IVR报表-IVR节点统计", "apiClinkReportData", "stat_ivr_nodes", getPath, String.valueOf(totalNum), String.valueOf(loopLimit), "获取数量:" + totalNum + " 获取条数:" + loopLimit, String.valueOf(System.currentTimeMillis() - startTime_Loop));

        return "总数量:" + totalNum + " 获取条数:" + loopLimit;

    }

    // 8.2. 座席报表
    static String stat_client(EliteBean eliteBean, JdbcTemplate jt, String StartTime) {

        //处理主数据
        log.debug("8.2. 座席报表 toDoGet Data StartTime:" + StartTime);

        long startTime_Loop = System.currentTimeMillis();
        int loopLimit = 0;

        // 系统接入-GET
        String getPath = "/cc/stat_client?";

        // 封装调用头Heads
        Map<String, String> headMap2 = new HashMap<String, String>();
        headMap2.put("Content-Type", "application/x-www-form-urlencoded");
        log.debug("8.2. 座席报表 系统接入 headMap:" + headMap2);

        Map<String, String> queryParams = new HashMap<String, String>();
        queryParams.put("date", StartTime);
        log.debug("8.2. 座席报表 系统接入 queryParams:" + queryParams);

        String doGETRes = ClinkUtils.doClinkCall2("POST", getPath, queryParams, headMap2, null);
        log.debug("8.2. 座席报表 系统接入 doGETRes:" + doGETRes);

        JSONObject doGETJSON = JSONObject.fromObject(doGETRes);
        log.debug("8.2. 座席报表 Data Result:" + doGETJSON);

        JSONArray dataArray = doGETJSON.getJSONArray("statClient"); ;
        int totalNum = dataArray.size();
        log.info("8.2. 座席报表 Data Result size:" + totalNum);

        // 初始化写入语句
        String insertSQL = '''Replace INTO clink_stat_client (date, cno, cname, totalBridgeDuration, totalDuration, ibTotalDuration, ibBridgeDuration, obTotalDuration, ibClientCount, ibTotalCount, obTotalCount, ibClientAnsweredCount, ibClientUnansweredCount, ibUnansweredAvgRingDuration, ibClientAnsweredRate, ibAnsweredCount, ibUnansweredCount, ibAnsweredRate, customerHangupCount, clientHangupCount, quickUnlinkCount, ibValidCount, ibValidDuration, ibAvgValidDuration, ibMaxBridgeDuration, ibMinBridgeDuration, ibAvgBridgeDuration, ibAvgAnswerDelayDuration, ibAnswerDelayDuration, ibMaxAnswerDelayDuration, ibMinAnswerDelayDuration, ibWrapUpDuration, ibMaxWrapUpDuration, ibMinWrapUpDuration, ibAvgWrapUpDuration, ibAvgHandleDuration, ibHoldDuration, ibHoldCount, ibAvgHoldDuration, ibTransferCount, ibTransferAnsweredCount, ibTransferUnansweredCount, ibTransferAnsweredRate, ibTransferredCount, ibTransferredAnsweredCount, ibTransferredAnsweredRate, ibTransferredUnansweredCount, ibConsultCount, ibConsultedCount, obAnsweredCount, obCustomerNoAnswerCount, obClientNoAnswerCount, obAnsweredWaitDuration, obAnsweredWaitAvgDuration, obNoAnsweredWaitDuration, obNoAnsweredWaitAvgDuration, obBridgeDuration, obMaxBridgeDuration, obMinBridgeDuration, obAvgBridgeDuration, obValidCount, obValidDuration, obAvgValidDuration, obAvgHoldDuration, obHoldDuration, obHoldCount, obWrapUpDuration, obAvgWrapUpDuration, internalBridgeCount, internalTotalCount, internalTotalDuration, internalBridgeDuration, internallyBridgeCount, internallyTotalCount, internallyTotalDuration, internallyBridgeDuration, firstIbBridgeCount, firstIbSolveRate, firstIbSolveCount, loginDuration, idleDuration, minIdleDuration, maxIdleDuration, workPauseDuration, minWorkPauseDuration, maxWorkPauseDuration, restPauseDuration, minRestPauseDuration, maxRestPauseDuration, hoursUtilization, workPauseRate, restPauseRate, lastLogoutTime, firstIdleTime, investigationTotalCount, abandonCount, keyCount, keyRate, ibRingingRangeCount10, ibRingingRangeCount15, ibRingingRangeCount20, ibRingingRangeRate10, ibRingingRangeRate15, ibRingingRangeRate20) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''';

        JSONObject dataObject = null;
        for (int i = 0; i < totalNum; i++) {
            dataObject = dataArray.getJSONObject(i);

            String date = KHUtil.GetSFJV(dataObject, "date");
            String cno = KHUtil.GetSFJV(dataObject, "cno");
            String cname = KHUtil.GetSFJV(dataObject, "cname");
            String totalBridgeDuration = KHUtil.GetSFJV(dataObject, "totalBridgeDuration");
            String totalDuration = KHUtil.GetSFJV(dataObject, "totalDuration");
            String ibTotalDuration = KHUtil.GetSFJV(dataObject, "ibTotalDuration");
            String ibBridgeDuration = KHUtil.GetSFJV(dataObject, "ibBridgeDuration");
            String obTotalDuration = KHUtil.GetSFJV(dataObject, "obTotalDuration");
            String ibClientCount = KHUtil.GetSFJV(dataObject, "ibClientCount");
            String ibTotalCount = KHUtil.GetSFJV(dataObject, "ibTotalCount");
            String obTotalCount = KHUtil.GetSFJV(dataObject, "obTotalCount");
            String ibClientAnsweredCount = KHUtil.GetSFJV(dataObject, "ibClientAnsweredCount");
            String ibClientUnansweredCount = KHUtil.GetSFJV(dataObject, "ibClientUnansweredCount");
            String ibUnansweredAvgRingDuration = KHUtil.GetSFJV(dataObject, "ibUnansweredAvgRingDuration");
            String ibClientAnsweredRate = KHUtil.GetSFJV(dataObject, "ibClientAnsweredRate");
            String ibAnsweredCount = KHUtil.GetSFJV(dataObject, "ibAnsweredCount");
            String ibUnansweredCount = KHUtil.GetSFJV(dataObject, "ibUnansweredCount");
            String ibAnsweredRate = KHUtil.GetSFJV(dataObject, "ibAnsweredRate");
            String customerHangupCount = KHUtil.GetSFJV(dataObject, "customerHangupCount");
            String clientHangupCount = KHUtil.GetSFJV(dataObject, "clientHangupCount");
            String quickUnlinkCount = KHUtil.GetSFJV(dataObject, "quickUnlinkCount");
            String ibValidCount = KHUtil.GetSFJV(dataObject, "ibValidCount");
            String ibValidDuration = KHUtil.GetSFJV(dataObject, "ibValidDuration");
            String ibAvgValidDuration = KHUtil.GetSFJV(dataObject, "ibAvgValidDuration");
            String ibMaxBridgeDuration = KHUtil.GetSFJV(dataObject, "ibMaxBridgeDuration");
            String ibMinBridgeDuration = KHUtil.GetSFJV(dataObject, "ibMinBridgeDuration");
            String ibAvgBridgeDuration = KHUtil.GetSFJV(dataObject, "ibAvgBridgeDuration");
            String ibAvgAnswerDelayDuration = KHUtil.GetSFJV(dataObject, "ibAvgAnswerDelayDuration");
            String ibAnswerDelayDuration = KHUtil.GetSFJV(dataObject, "ibAnswerDelayDuration");
            String ibMaxAnswerDelayDuration = KHUtil.GetSFJV(dataObject, "ibMaxAnswerDelayDuration");
            String ibMinAnswerDelayDuration = KHUtil.GetSFJV(dataObject, "ibMinAnswerDelayDuration");
            String ibWrapUpDuration = KHUtil.GetSFJV(dataObject, "ibWrapUpDuration");
            String ibMaxWrapUpDuration = KHUtil.GetSFJV(dataObject, "ibMaxWrapUpDuration");
            String ibMinWrapUpDuration = KHUtil.GetSFJV(dataObject, "ibMinWrapUpDuration");
            String ibAvgWrapUpDuration = KHUtil.GetSFJV(dataObject, "ibAvgWrapUpDuration");
            String ibAvgHandleDuration = KHUtil.GetSFJV(dataObject, "ibAvgHandleDuration");
            String ibHoldDuration = KHUtil.GetSFJV(dataObject, "ibHoldDuration");
            String ibHoldCount = KHUtil.GetSFJV(dataObject, "ibHoldCount");
            String ibAvgHoldDuration = KHUtil.GetSFJV(dataObject, "ibAvgHoldDuration");
            String ibTransferCount = KHUtil.GetSFJV(dataObject, "ibTransferCount");
            String ibTransferAnsweredCount = KHUtil.GetSFJV(dataObject, "ibTransferAnsweredCount");
            String ibTransferUnansweredCount = KHUtil.GetSFJV(dataObject, "ibTransferUnansweredCount");
            String ibTransferAnsweredRate = KHUtil.GetSFJV(dataObject, "ibTransferAnsweredRate");
            String ibTransferredCount = KHUtil.GetSFJV(dataObject, "ibTransferredCount");
            String ibTransferredAnsweredCount = KHUtil.GetSFJV(dataObject, "ibTransferredAnsweredCount");
            String ibTransferredAnsweredRate = KHUtil.GetSFJV(dataObject, "ibTransferredAnsweredRate");
            String ibTransferredUnansweredCount = KHUtil.GetSFJV(dataObject, "ibTransferredUnansweredCount");
            String ibConsultCount = KHUtil.GetSFJV(dataObject, "ibConsultCount");
            String ibConsultedCount = KHUtil.GetSFJV(dataObject, "ibConsultedCount");
            String obAnsweredCount = KHUtil.GetSFJV(dataObject, "obAnsweredCount");
            String obCustomerNoAnswerCount = KHUtil.GetSFJV(dataObject, "obCustomerNoAnswerCount");
            String obClientNoAnswerCount = KHUtil.GetSFJV(dataObject, "obClientNoAnswerCount");
            String obAnsweredWaitDuration = KHUtil.GetSFJV(dataObject, "obAnsweredWaitDuration");
            String obAnsweredWaitAvgDuration = KHUtil.GetSFJV(dataObject, "obAnsweredWaitAvgDuration");
            String obNoAnsweredWaitDuration = KHUtil.GetSFJV(dataObject, "obNoAnsweredWaitDuration");
            String obNoAnsweredWaitAvgDuration = KHUtil.GetSFJV(dataObject, "obNoAnsweredWaitAvgDuration");
            String obBridgeDuration = KHUtil.GetSFJV(dataObject, "obBridgeDuration");
            String obMaxBridgeDuration = KHUtil.GetSFJV(dataObject, "obMaxBridgeDuration");
            String obMinBridgeDuration = KHUtil.GetSFJV(dataObject, "obMinBridgeDuration");
            String obAvgBridgeDuration = KHUtil.GetSFJV(dataObject, "obAvgBridgeDuration");
            String obValidCount = KHUtil.GetSFJV(dataObject, "obValidCount");
            String obValidDuration = KHUtil.GetSFJV(dataObject, "obValidDuration");
            String obAvgValidDuration = KHUtil.GetSFJV(dataObject, "obAvgValidDuration");
            String obAvgHoldDuration = KHUtil.GetSFJV(dataObject, "obAvgHoldDuration");
            String obHoldDuration = KHUtil.GetSFJV(dataObject, "obHoldDuration");
            String obHoldCount = KHUtil.GetSFJV(dataObject, "obHoldCount");
            String obWrapUpDuration = KHUtil.GetSFJV(dataObject, "obWrapUpDuration");
            String obAvgWrapUpDuration = KHUtil.GetSFJV(dataObject, "obAvgWrapUpDuration");
            String internalBridgeCount = KHUtil.GetSFJV(dataObject, "internalBridgeCount");
            String internalTotalCount = KHUtil.GetSFJV(dataObject, "internalTotalCount");
            String internalTotalDuration = KHUtil.GetSFJV(dataObject, "internalTotalDuration");
            String internalBridgeDuration = KHUtil.GetSFJV(dataObject, "internalBridgeDuration");
            String internallyBridgeCount = KHUtil.GetSFJV(dataObject, "internallyBridgeCount");
            String internallyTotalCount = KHUtil.GetSFJV(dataObject, "internallyTotalCount");
            String internallyTotalDuration = KHUtil.GetSFJV(dataObject, "internallyTotalDuration");
            String internallyBridgeDuration = KHUtil.GetSFJV(dataObject, "internallyBridgeDuration");
            String firstIbBridgeCount = KHUtil.GetSFJV(dataObject, "firstIbBridgeCount");
            String firstIbSolveRate = KHUtil.GetSFJV(dataObject, "firstIbSolveRate");
            String firstIbSolveCount = KHUtil.GetSFJV(dataObject, "firstIbSolveCount");
            String loginDuration = KHUtil.GetSFJV(dataObject, "loginDuration");
            String idleDuration = KHUtil.GetSFJV(dataObject, "idleDuration");
            String minIdleDuration = KHUtil.GetSFJV(dataObject, "minIdleDuration");
            String maxIdleDuration = KHUtil.GetSFJV(dataObject, "maxIdleDuration");
            String workPauseDuration = KHUtil.GetSFJV(dataObject, "workPauseDuration");
            String minWorkPauseDuration = KHUtil.GetSFJV(dataObject, "minWorkPauseDuration");
            String maxWorkPauseDuration = KHUtil.GetSFJV(dataObject, "maxWorkPauseDuration");
            String restPauseDuration = KHUtil.GetSFJV(dataObject, "restPauseDuration");
            String minRestPauseDuration = KHUtil.GetSFJV(dataObject, "minRestPauseDuration");
            String maxRestPauseDuration = KHUtil.GetSFJV(dataObject, "maxRestPauseDuration");
            String hoursUtilization = KHUtil.GetSFJV(dataObject, "hoursUtilization");
            String workPauseRate = KHUtil.GetSFJV(dataObject, "workPauseRate");
            String restPauseRate = KHUtil.GetSFJV(dataObject, "restPauseRate");
            String lastLogoutTime = KHUtil.GetSFJV(dataObject, "lastLogoutTime");
            String firstIdleTime = KHUtil.GetSFJV(dataObject, "firstIdleTime");
            String investigationTotalCount = KHUtil.GetSFJV(dataObject, "investigationTotalCount");
            String abandonCount = KHUtil.GetSFJV(dataObject, "abandonCount");
            String keyCount = KHUtil.GetSFJV(dataObject, "keyCount");
            String keyRate = KHUtil.GetSFJV(dataObject, "keyRate");
            String ibRingingRangeCount10 = KHUtil.GetSFJV(dataObject, "ibRingingRangeCount10");
            String ibRingingRangeCount15 = KHUtil.GetSFJV(dataObject, "ibRingingRangeCount15");
            String ibRingingRangeCount20 = KHUtil.GetSFJV(dataObject, "ibRingingRangeCount20");
            String ibRingingRangeRate10 = KHUtil.GetSFJV(dataObject, "ibRingingRangeRate10");
            String ibRingingRangeRate15 = KHUtil.GetSFJV(dataObject, "ibRingingRangeRate15");
            String ibRingingRangeRate20 = KHUtil.GetSFJV(dataObject, "ibRingingRangeRate20");

            // 数据入库
            jt.update(insertSQL, date, cno, cname, totalBridgeDuration, totalDuration, ibTotalDuration, ibBridgeDuration, obTotalDuration, ibClientCount, ibTotalCount, obTotalCount, ibClientAnsweredCount, ibClientUnansweredCount, ibUnansweredAvgRingDuration, ibClientAnsweredRate, ibAnsweredCount, ibUnansweredCount, ibAnsweredRate, customerHangupCount, clientHangupCount, quickUnlinkCount, ibValidCount, ibValidDuration, ibAvgValidDuration, ibMaxBridgeDuration, ibMinBridgeDuration, ibAvgBridgeDuration, ibAvgAnswerDelayDuration, ibAnswerDelayDuration, ibMaxAnswerDelayDuration, ibMinAnswerDelayDuration, ibWrapUpDuration, ibMaxWrapUpDuration, ibMinWrapUpDuration, ibAvgWrapUpDuration, ibAvgHandleDuration, ibHoldDuration, ibHoldCount, ibAvgHoldDuration, ibTransferCount, ibTransferAnsweredCount, ibTransferUnansweredCount, ibTransferAnsweredRate, ibTransferredCount, ibTransferredAnsweredCount, ibTransferredAnsweredRate, ibTransferredUnansweredCount, ibConsultCount, ibConsultedCount, obAnsweredCount, obCustomerNoAnswerCount, obClientNoAnswerCount, obAnsweredWaitDuration, obAnsweredWaitAvgDuration, obNoAnsweredWaitDuration, obNoAnsweredWaitAvgDuration, obBridgeDuration, obMaxBridgeDuration, obMinBridgeDuration, obAvgBridgeDuration, obValidCount, obValidDuration, obAvgValidDuration, obAvgHoldDuration, obHoldDuration, obHoldCount, obWrapUpDuration, obAvgWrapUpDuration, internalBridgeCount, internalTotalCount, internalTotalDuration, internalBridgeDuration, internallyBridgeCount, internallyTotalCount, internallyTotalDuration, internallyBridgeDuration, firstIbBridgeCount, firstIbSolveRate, firstIbSolveCount, loginDuration, idleDuration, minIdleDuration, maxIdleDuration, workPauseDuration, minWorkPauseDuration, maxWorkPauseDuration, restPauseDuration, minRestPauseDuration, maxRestPauseDuration, hoursUtilization, workPauseRate, restPauseRate, lastLogoutTime, firstIdleTime, investigationTotalCount, abandonCount, keyCount, keyRate, ibRingingRangeCount10, ibRingingRangeCount15, ibRingingRangeCount20, ibRingingRangeRate10, ibRingingRangeRate15, ibRingingRangeRate20);
            loopLimit++;

        }

        LogToDB.toSyncFile_Log(eliteBean, Oper_No + KHUtil.getIntRandom(4), "8.2. 座席报表", "apiClinkReportData", "stat_client", getPath, String.valueOf(totalNum), String.valueOf(loopLimit), "获取数量:" + totalNum + " 获取条数:" + loopLimit, String.valueOf(System.currentTimeMillis() - startTime_Loop));

        return "总数量:" + totalNum + " 获取条数:" + loopLimit;

    }
}